
<%@ page import="pc.system.*,wstrader.*,wstrader.task.*" %>

<%
    Users user = Trader.getUser(request.getParameter("uid"));
	
	if (user == null || !user.Authenticated()) {
		response.sendRedirect("logon.jsp");	
		return;
	}
	
	wstrader.task.trade.Futures ftask = user.trade.futures;
	wstrader.task.trade.futures.Transactions task = user.trade.futures.transactions;
	((Tasks)ftask.getOwner()).clearFocus();
	ftask.setFocus(true);
	//ftask.forwardToChild(user.getuid());	
	ResultSet rs;		
%>

<%@include file="../header.jsp"%>

<%
	long focused_id = task.doTask();
	//if (focused_id <= 0) focused_id = 1;
	//Record rc   = task.getRecord("purchase_contract",focused_id);
%>

<link href="style.css" rel="stylesheet" type="text/css">

<script language="javascript">
function doAddNew()
{
	var form = document.formMain;
	form.new_rec.value = "1";
	form.action = "trade.futures.transactions.card.jsp";
	form.submit();
}

function doFilter()
{
	var form = document.formMain;
	form.action = "trade.futures.jsp";
	form.submit();
}

function clickCardView(row)
{
	var form = document.formMain;
	if (row == null) row = old_row_obj;
	form.action = "trade.futures.transactions.card.jsp";
	form.submit();	
}

function doCloseOut()
{
	var form = document.formMain;
	var sold = form.tot_cl_sold.value;
	var bot = form.tot_cl_bot.value
	
	if ((sold-bot) == 0) 
	{
		doTask(3);
	}
	else
	{
		alert("No of bot closed does not match with no of sold closed");	
	}

}

function cardViewClick(row)
{
	var form = document.formMain;
	form.futures_contract.value = (row.id).substring(2);
	dblClick(row);
}

function doOptCheck(chb)
{
 	var form = document.formMain;
	var cl_lot =0;
	var type ="";
	var b = 0;
	var s = 0;
	form.sel_id.value ="";
	for (var i = 1;; i++)
	{
		var inv_id = getObj("cb_" + i);
		if (inv_id == null) break;
		if (inv_id != null) cl_lot = getValue("cb_" + i) *1; 
		
		if (inv_id.checked) 
		{
			var v = getText("inv_id_" + i);
			var l = 0;
			l = getText("lot_id_" + i);
			type = getValue("type_id_" + i);
			
			if (type == 'P') b = (b*1) + (l*1);
			if (type == 'S') s = (s*1) + (l*1);

			if (form.sel_id.value=="")
			{
				form.sel_id.value=  v;
			}
			else
				{
					form.sel_id.value=  form.sel_id.value+"," + v;
				}
		}
		
	}
	form.tot_cl_bot.value = b;
	form.tot_cl_sold.value = s;
}
</script>
<style type="text/css">
<!--
.style3 {font-family: Arial}
.style6 {font-size: 12px}
-->
</style>
<form action="" method="post" name="formMain" id="formMain">
  <table width="100%"  border="0" cellpadding="1" cellspacing="1">
    <tr>
      <td height="22" align="center" bgcolor="#FFFFFF"><strong></strong></td>
      <td width="150">&nbsp;</td>
      <td width="160">&nbsp;</td>
      <td width="150">&nbsp;</td>
      <td width="150">&nbsp;</td>
      <td colspan="3">&nbsp;</td>
      <td colspan="2"><input name="futures_contract" type="hidden" id="futures_contract" value="0">
      <input name="sel_id" type="hidden" id="sel_id">
      <input name="tot_cl_bot" type="hidden" id="tot_cl_bot" value="0">
      <input name="tot_cl_sold" type="hidden" id="tot_cl_sold" value="0"></td>
    </tr>
    <tr>
      <td width="150" align="center" bgcolor="#EEEEEE"><strong><span class="style29 style3 style6">Transaction Date</span></strong></td>
      <td align="center" bgcolor="#EEEEEE"><strong><span class="style29 style3 style6">Trans. Ref.No. </span></strong></td>
      <td align="center" bgcolor="#EEEEEE"><strong><span class="style29 style3 style6">Bot/Sold</span></strong></td>
      <td align="center" bgcolor="#EEEEEE"><strong><span class="style29 style3 style6">Ter.Market</span></strong></td>
      <td align="center" bgcolor="#EEEEEE"><strong><span class="style29 style3 style6">Broker</span></strong></td>
      <td colspan="3" align="center" bgcolor="#EEEEEE"><strong><span class="style29 style3 style6">Ter.Month</span></strong></td>
      <td colspan="2" align="center" bgcolor="#EEEEEE"><strong></strong></td>
    </tr>
    <tr>
      <td height="32">
	  <select name="cnt_dt" size="9" id="cnt_dt" onChange="doFilter()" style="font-family:Arial; font-size:11px; width:150px;border:0">
		<%@include file="include/FuturesContractDateList.jsp"%>
      </select>
	  </td>
      <td>
	  <select name="fcnt_cnt_no" size="9" id="fcnt_cnt_no" onChange="doFilter()" style="font-family:Arial; font-size:11px; width:150px;border:0">
		  <option value="0" selected>All</option>
	  	<%
			task.getResponse().setOption("futures_contract","ref_number");
			task.getResponse().setSelected("fcnt_cnt_no");
		%>	  
      </select>
	  </td>
      <td>
	  <select name="bot_sold" size="9" id="bot_sold" onChange="doFilter()" style="font-family:Arial; font-size:11px; width:160px;border:0">
        <option value="0" selected>All</option>
        <option value="B">BOT</option>
        <option value="S">SOLD</option>
        <%task.getResponse().setSelected("bot_sold");%>
	  </select>
	  </td>
      <td><select name="ter_mrk" size="9" id="ter_mrk" onChange="doFilter()" style="font-family:Arial; font-size:11px; width:150px;border:0">
        <option value="0" selected>All</option>
        <option value="NYC">NYC</option>
        <option value="LIFFE">LIFFE</option>
        <%task.getResponse().setSelected("ter_mrk");%>
      </select>
	  </td>
      <td><select name="broker" size="9" id="broker" onChange="doFilter()" style="font-family:Arial; font-size:11px; width:150px;border:0">
        <option value="0" selected>All</option>
	  			<%
					task.getResponse().setOption("futures_account_master","name");
					task.getResponse().setSelected("broker");
				%>	  
      </select></td>
      <td colspan="3"><select name="ter_mth" size="9" id="ter_mth" onChange="doFilter()" style="font-family:Arial; font-size:11px; width:150px;border:0">
        <%@include file="include/TerminalMonthList.jsp"%>
      </select></td>
      <td colspan="2">&nbsp;
	  </td>
    </tr>
    <tr>
      <td height="32" colspan="10" valign="top">
	  <table width="100%" height = "30"  border="1" cellpadding="0" cellspacing="0" bordercolor="#EEEEEE">
        <tr bordercolor="#FFFBF0">
          <td width="6%" align="center" bgcolor="#EEEEEE"><strong><span class="style29 style3 style6">Id</span></strong></td>
          <td width="17%" align="center" bgcolor="#EEEEEE"><strong><span class="style29 style3 style6">Trn.Ref.No</span></strong></td>
          <td width="12%" align="center" bgcolor="#EEEEEE"><strong><span class="style29 style3 style6">Trn.Date</span></strong></td>
          <td width="18%" align="center" bgcolor="#EEEEEE"><strong><span class="style29 style3 style6">Lots</span></strong></td>
          <td width="13%" align="center" bgcolor="#EEEEEE"><strong><span class="style29 style3 style6">Bot/Sold</span></strong></td>
          <td width="13%" align="center" bgcolor="#EEEEEE"><strong><span class="style29 style3 style6">Ter.Mth</span></strong></td>
          <td width="14%" align="center" bgcolor="#EEEEEE"><strong><span class="style29 style3 style6">Price</span></strong></td>
          <td width="7%" align="center" bgcolor="#EEEEEE"><strong><span class="style29 style3 style6">Close Out </span></strong></td>
          </tr>
		<tr>
		<td colspan="8">
		<DIV id=scroll1 style="BORDER:0px ; OVERFLOW: auto; WIDTH: 100%; HEIGHT: 260px;">
			<%@include file="trade.futures.transactions.list.details.jsp"%>
		</DIV>
		</td>
		</tr>
      </table>
	  </td>
    </tr>
	
	
	
    <tr>
      <td>&nbsp;</td>
      <td>&nbsp;</td>
      <td>&nbsp;</td>
      <td>&nbsp;</td>
      <td align="center">&nbsp;</td>
      <td colspan="3" align="center">&nbsp;</td>
      <td colspan="2" align="center">&nbsp;</td>
    </tr>
    <tr>
      <td>
	  <img src="images/new.gif"  onclick="doAddNew();" width="15" height="15" />
	  <input type="hidden" name="uid"        id="uid"       value="<%=user.getuid()%>">
      <input type="hidden" name="task_id"    id = "task_id"   value="0">
	  <input type="hidden" name="new_rec"    id = "new_rec"   value="0" /></td>
      <td>&nbsp;</td>
      <td>&nbsp;</td>
      <td>&nbsp;</td>
      <td colspan="2" align="right"><strong><span class="style29 style3 style6">Close Out Date: </span></strong></td>
      <td width="134" align="right"><input name="close_out_date" type="text" id="close_out_date" style="width:88px">      </td>
      <td width="33" align="left"><img src="js/calendar.gif" width="20" height="20" align="absmiddle" onClick="popUpCalendar(this,'close_out_date','dd-mmm-yy');"></td>
      <td width="59" align="center" valign="middle"><img src="images/close-out.jpg" width="55" height="18" onClick="doCloseOut();"></td>
      <td width="65" align="center"><img src="images/cardview.jpg" width="55" height="18" onClick="clickCardView()"></td>
    </tr>
  </table>
</form>
<%@include file="../footer.jsp"%>

